const mysql = require('../mysql/index')

var returnAllArticle = async (ctx, next) => {
  let data = await mysql.queryAll('article');
  ctx.response.body = {
    code: '00',
    message: 'success',
    data: data
  }
}
var createArticle = async (ctx, next) => {
  let res = ctx.request.body;
  let dataShee = 'article';
  let keys = "(user_id,art_title,art_tab,art_content,atr_create_time,art_modify_time)";
  let time = new Date().toLocaleDateString().replace(/\//g, "-");
  let values = `("693765678","${res.title}","${res.tap}",'${res.content}',"${time}","${time}")`;
console.log(values)
  console.log(dataShee, keys, values)
  let data = await mysql.insert(dataShee, keys, values)
  ctx.response.body = {
    code: '00',
    message: 'srccess',
    data: data
  }
}


module.exports = {
  'POST /article/getArticle': createArticle,
  'POST /article/getAllArticle': returnAllArticle
}